# Contributor: Holger Jaekel <holger.jaekel@gmx.de>
# Maintainer: Holger Jaekel <holger.jaekel@gmx.de>
pkgname=cfitsio
pkgver=4.1.0
pkgrel=0
pkgdesc="A library reading and writing data files in Flexible Image Transport System data format"
url="https://heasarc.gsfc.nasa.gov/fitsio/"
arch="all"
license="custom"
makedepends="
	bzip2-dev
	curl-dev
	gfortran
	"
subpackages="
	$pkgname-static
	$pkgname-dev
	"
source="
	https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-$pkgver.tar.gz
	10-OFF_T.patch
	"

build() {
	./configure \
		--prefix=/usr \
		--with-bzip2 \
		--enable-reentrant \
		--enable-sse2 \
		--enable-ssse3 \
		--enable-hera
	make shared
	make utils
}

package() {
	make DESTDIR="$pkgdir" install
	mkdir -p "$pkgdir"/usr/share/licenses/cfitsio/
	cp License.txt "$pkgdir"/usr/share/licenses/cfitsio/

	# delete test/demo programs
	rm "$pkgdir"/usr/bin/testprog
	rm "$pkgdir"/usr/bin/cookbook

	# avoid conflicts with smem
	rm "$pkgdir"/usr/bin/smem
}

check() {
	LD_LIBRARY_PATH=. ./testprog > testprog.lis
	[[ -z $(diff testprog.lis testprog.out) ]]
	[[ -z $(cmp testprog.fit testprog.std) ]]
}
sha512sums="
bbbe10e890e74a30a9806dd2bbf711b3b1f15502b210b222d2d57cc083495c3b66b44927e4680f989045187fb7075f7187e2805ddcb4753ce53c68c3442cc813  cfitsio-4.1.0.tar.gz
5b5a2f932e837a86ae4dd4cf035c2a0ee27c27b7f06f24375ef29312c8836f03d688c66e3cdf19b4617859f9845f602d13017a8564803408eec9d7f928ced6bc  10-OFF_T.patch
"
